﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Luna.Extender;
using System.Windows.Forms;
using System.Reflection;
using System.Xml;

namespace Luna.Framework.Extender
{
	class XmlFormExtentionItem : XmlExtensionItem, IFormExtensionItem
	{
		internal XmlFormExtentionItem(XmlExtensionManager manager, XmlNode node) : base(manager, node) { }

		#region IFormExtensionItem Members

		public string FormName {
			get {
				return (string)this["name"];
			}
			set {
				this["name"] = value;
			}
		}

		public FormType FormType {
			get {
				return (FormType)Enum.Parse(typeof(FormType), (string)this["type"], true);
			}
			set {
				this["type"] = value.ToString();
			}
		}

		public bool CreateOnStartup {
			get {
				return "true".Equals(this["createOnStartup"]);
			}
			set {
				this["createOnStartup"] = value.ToString();
			}
		}

		public override object createExtension(IAppContext context) {
			Form form = (Form) base.createExtension(context);
			if (form != null) {
				form.setPropertyValue("Name", FormName, null);
			}
			return  form;
		}

		#endregion

		
	}
}
